<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: register.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."register.php";
include LOCALE.LOCALESET."user_fields.php";

	


If (isset($_POST['fornavn']) 
&& isset($_POST['etternavn']) 
&& isset($_POST['adresse']) 
&& isset($_POST['postnr'])
&& isset($_POST['telefon'])
&& isset($_POST['type'])
&& isset($_POST['mobil'])
&& isset($_POST['epost'])
&& isset($_POST['aktiv'])
&& isset($_POST['agronom'])
&& isset($_POST['paanavn'])
&& isset($_POST['paatlf']))
{
	$fornavn=$_POST['fornavn'];
	$etternavn=$_POST['etternavn'];
	$adresse=$_POST['adresse'];
	$postnr=$_POST['postnr'];
	$telefon=$_POST['telefon'];
	$mobil=$_POST['mobil'];
	$epost=$_POST['epost'];
	$aktiv=$_POST['aktiv'];
	$agronom=$_POST['agronom'];
	$paarorendenavn=$_POST['paanavn'];
	$paarorendetlf=$_POST['paatlf'];
	$selected=implode(',',$_POST['type']); 
	
	$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
	mysql_select_db($GLOBALS['db_name'], $db);  
		
	$query = "INSERT INTO avloser VALUES ('','$fornavn','$etternavn','$adresse','$postnr','$telefon','$mobil','$epost',
			 '$aktiv', '$agronom', '$selected', '$paarorendenavn', '$paarorendetlf', '')";
	
	mysql_query($query);
	
	$ret =  mysql_insert_id();
	
	opentable($locale['401']);
	header("Refresh: 1; url='profil.php?avloserid=$ret'");
	closetable();

}else{
	
	echo" <h1>Du ma fylle ut alle feltene!</h1>";
	
	echo "<br></br><table class='capmain' border='0' cellpadding='0' align='center' width='608px'>
<tr><th>Ny ansatt</th></tr></table>
<table class='imagetable' table border='0' cellpadding='5' align='center'>
<form action='ny.php' method='post'>
<tr>
<th>Etternavn </th><td colspan='2'><input type='text' name='etternavn' value='$etternavn'></td>
</tr><tr>
<th>Fornavn </th><td colspan='2'><input type='text' name='fornavn' value='$fornavn'></td>
</tr><tr>
<th>Mobil </th><td colspan='2'><input type='text' name='mobil' value='$mobil'></td>
</tr><tr>
<th>Adresse </th><td colspan='2'><input type='text' name='adresse' value='$adresse'></td>
</tr><tr>
<th>Postnr </th><td colspan='2'><input type='text' name='postnr' value='$postnr'></td>
</tr><tr>
<th>Telefon </th><td colspan='2'><input type='text' name='telefon' value='$telefon'></td>
</tr><tr>
<th>Epost </th><td colspan='2'><input type='text' name='epost' value='$epost'></td>
</tr><tr>
<th>P&aring;r&oslash;rende </th><td colspan='2'><input type='text' name='paanavn' value='$paarorendenavn'></td>
</tr><tr>
<th>P&aring;r&oslash;rendetlf </th><td colspan='2'><input type='text' name='paatlf' value='$paarorendetlf'></td>
</tr><tr>
"/*<th>Aktiv </th><td><SELECT NAME='aktiv'><OPTION VALUE=0>$options</SELECT></td>*/."
<th>Aktiv:</th>

<td colspan='2'>";		
	if ($aktiv == 'JA') {
		echo "<b>Ja: </b><input type='radio' name='aktiv' value='JA' checked='checked' /><b>Nei: </b><input type='radio' name='aktiv' value='NEI'/>";
	}
	else if ($aktiv == 'NEI') {    
	echo "<b>Ja: </b><input type='radio' name='aktiv' value='JA'/><b>Nei: </b><input type='radio' name='aktiv' value='NEI' checked='checked' />";
	}
	else  {
	echo"<b>Ja: </b><input type='radio' name='aktiv' value='JA'/><b>Nei: </b><input type='radio' name='aktiv' value='NEI'/>";
	}
	echo"	</td>		</tr>
																										
<tr>	<th><b>AgronomUtd</b></th>		<td>";	
	
	if ($agronom == 'JA') {
		echo "<b>Ja: </b><input type='radio' name='agronom' value='JA' checked='checked' />";
	}
	else {    
		echo "<b>Ja: </b><input type='radio' name='agronom' value='JA'/>";
	}
	if ($agronom == 'NEI') {
		echo "<b>Nei: </b><input type='radio' name='agronom' value='NEI' checked='checked' />";
	}
	else {    
		echo "<b>Nei: </b><input type='radio' name='agronom' value='NEI'/>";
	}
			
														echo"	</td>		</tr>

<tr>
<th>Type</th><td colspan='2'><b>Administrasjon:</b><input type='checkbox' name='type[]' value='Administrasjon'><b>Avl&oslash;ser:</b><input type='checkbox' name='type[]' value='Avl&oslash;ser'><b>Annen n&aelig;ring:</b><input type='checkbox' name='type[]' value='Annen n&aelig;ring'><b>Utenlandsk arb.kraft:</b><input type='checkbox' name='type[]' value='Utenlandsk arb.kraft'></td>
</tr><tr>
<th><input type='Submit' value='Legg til'></th><td colspan='2'></td>
</tr>
</form></table>";
} //Slutt Else

require_once THEMES."templates/footer.php";
?>